const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('article', {
    article_id: {
      autoIncrement: true,
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true
    },
    title: {
      type: DataTypes.STRING(100),
      allowNull: true,
      defaultValue: "",
      comment: "文章标题"
    },
    content: {
      type: DataTypes.TEXT,
      allowNull: true,
      comment: "文章内容"
    },
    publish_date: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "发布日期"
    },
    intro: {
      type: DataTypes.STRING(200),
      allowNull: true,
      defaultValue: "",
      comment: "文章简介"
    },
    views: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "文章阅读的次数"
    },
    status: {
      type: DataTypes.TINYINT,
      allowNull: true,
      defaultValue: 0,
      comment: "文章状态： 0-未发布 1-已发布"
    },
    cover: {
      type: DataTypes.STRING(200),
      allowNull: true,
      defaultValue: "",
      comment: "文章封面图"
    },
    tag_ids: {
      type: DataTypes.STRING(100),
      allowNull: true,
      defaultValue: "",
      comment: "所属标签： 1-2-3"
    },
    category_id: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "所属分类"
    },
    is_admin: {
      type: DataTypes.TINYINT,
      allowNull: true,
      defaultValue: 0,
      comment: "是否是管理员发布的： 0-不是，1-是"
    },
    add_date: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "添加时间"
    },
    update_date: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "修改时间"
    },
    user_id: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "关联会员id"
    },
    admin_id: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "关联管理员id"
    },
    good_count: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "点赞的总数"
    },
    collect_count: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "收藏的数量"
    }
  }, {
    sequelize,
    tableName: 'article',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "article_id" },
        ]
      },
    ]
  });
};
